﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="ug.js"></script>
    <script src="./aaencode.js"></script>
	<script src="./aadecode.js"></script>
	<script src="./jjencode.js"></script>
</head>
<body>
    <div>
        输入：
        <textarea id="tt" style="width:90%" rows="10"></textarea>
    </div>

    <button type="button" onclick="document.getElementById('a').value=ug(document.getElementById('tt').value)">压缩混淆</button>
    <button type="button" onclick="document.getElementById('a').value=aaencode(document.getElementById('tt').value)">aaencode</button>
    <button type="button" onclick="document.getElementById('a').value=aadecode(document.getElementById('tt').value)">aadecode</button>
    <button type="button" onclick="document.getElementById('a').value=jjencode('_', document.getElementById('tt').value)">jjencode</button>
    
    <div>
        输出：
        <textarea id="a" style="width:90%" rows="5"></textarea>
    </div>
    <div>
        <h1>禁用用户控制台js</h1>
        <textarea  style="width:90%" rows="10">// It appears Netflix is following (Facebook's lead)[https://news.ycombinator.com/item?id=7222129].(function() {
    try {
        var $_console$$ = console;
        Object.defineProperty(window, "console", {
            get: function() {
                if ($_console$$._commandLineAPI)
                    throw "Sorry, for security reasons, the script console is deactivated on netflix.com";
                return $_console$$            },
            set: function($val$$) {
                $_console$$ = $val$$            }
        })
    } catch ($ignore$$) {
    }})();</textarea>
    </div>
    <div>
        <h1>前端防止 JS 调试</h1>
        <textarea  style="width:90%" rows="15">简单模式：
setInterval(function() {
    debugger
}, 100);

稍微复杂一点：
function t() {
    try {
        var a = ["r", "e", "g", "g", "u", "b", "e", "d"].reverse().join("");
        ! function e(n) {
            (1 !== ("" + n / n).length || 0 === n) && function() {}
            .constructor(a)(),
            e(++n)
        }(0)
    } catch (a) {
        setTimeout(t, 500)
    }
}</textarea>
    </div>

<div>
    <div>JS闭包封装网站防护调试函数</div>
    <textarea   style="width:90%" rows="20">var protection = (function() {
        var data = {
            suffix: "com",
            main: "www.",
            red: "bai",
            beauty: "du",
            dot: "."
        }
        var d = (data.main + data.red + data.beauty).toString() + data.dot + data.suffix;
        // 如果当前URL不是设定的URL，则跳转
        var url = function() {
            if (document.location.host != "www.baidu.com") {
                location.href = location.href.replace(document.location.host, 'www.baidu.com');
            }
            return location.href;
        }
        // 复制文件到本地，打开白屏
        var authentication = function() {
            if (window.location.host.indexOf(d) < 0) {
                $("body").remove();
                //document.querySelector('html').removeChild('body');
                return false
            }
            return true
        }
        // 防止打开右键
        var disableMouseRight = function() {
            $(document).ready(function() {
                $(document).on("contextmenu", function(e) {
                    e.preventDefault();
                    return false;
                });
            });
        }
        var shield = function(config) {
            shield.config = config;
            var disable = {
                disableCopy: function(e, keycode) {
                    //屏蔽Ctrl+s 保存页面
                    if (e.ctrlKey && keycode == 83) {
                        console.log(shield.config)
                        e.preventDefault();
                        e.returnValue = false;
                    }
                },
                disableSource: function(e, keycode) {
                    //屏蔽Ctrl+u  查看页面的源代码
                    if (e.ctrlKey && keycode == 85) {
                        e.preventDefault();
                        e.returnValue = false;
                    }
                },
                disableF12: function(e, keycode) {
                    //屏蔽F12
                    if (keycode == 123) {
                        e.preventDefault();
                        e.returnValue = false;
                        //  $("body").remove();
                        window.location.href = "about:blank";
                        window.close();
                    }
                },
                disableConsole: function(e, keycode) {
                    //屏蔽Ctrl+shift+i   屏蔽调出控制台 和F12一样
                    if (e.ctrlKey && e.shiftKey && keycode == 73) {
                        $("body").remove();
                        e.preventDefault();
                        e.returnValue = false;
                    }
                }
            }
            document.addEventListener('keydown', function(e) {
                e = window.event || e;
                var keycode = e.keyCode || e.which;
                for (var i = 0; i < shield.config.length; i++) {
                    disable[shield.config[i]](e, keycode);
                }
            });
        }
        var facility = {
            geturl: url,
            checkurl: authentication,
            disableright: disableMouseRight,
            shield: shield
        }
        return facility;
    })();
    /* 启动防护盾 */
    //确保URL唯一正确
    protection.geturl();
    //防止本地打开
    protection.checkurl();
    //禁止右键
    protection.disableright();
    //禁止键盘快捷键
    //protection.shield(["disableCopy", "disableConsole", "disableSource", "disableF12"]);</textarea>
</div>


    <script>
        function doit() {
            var t = document.getElementById("tt").value;
            var c = ug(t);
            document.getElementById("a").value = c;
        }
    </script>
</body>
</html>